//
//  ZHNetworkingCacheModel.m
//  ToolsEnginer
//
//  Created by 正合适 on 2017/6/2.
//  Copyright © 2017年 正合适. All rights reserved.
//

#import "ZHNetworkingCacheModel.h"

@implementation ZHNetworkingCacheModel

#pragma mark - 判断缓存是否过期-小于0：不缓存 等于0:永久缓存 大于0：缓存时间
- (BOOL)isExpire {
    if (self.expireTime == 0) {
        return NO;
    } else if (self.expireTime < 0) {
        return YES;
    } else {
        NSTimeInterval currentInterval = [ZHNetworkingCacheModel currentTime];
        if (self.saveTime+self.expireTime <= currentInterval) {
            return YES;
        } else {
            return NO;
        }
    }
}

+ (NSTimeInterval)currentTime {
    return [[NSDate date] timeIntervalSince1970];
}

@end
